package com.la100.common.utils;

import java.util.UUID;

/**
 * 字符串工具类
 * 
 * @author lishi
 * @date 2017-11-29 下午8:52:12
 */
public class StringUtils {
	
	public static String getRandomWithTimestamp(int length)throws Exception{
		if(length < 20 || length > 40) {
			throw new Exception("if the length small than 20 large than 32,not advise use this method!");
		}
		
		int startIndex = 32 - length + 13; // UUID字符串去掉"-"长度为32。 时间戳占12位长度
		return System.currentTimeMillis() + UUID.randomUUID().toString().replaceAll("-", "").substring(startIndex);
	}
	
	public static boolean isBank(String str) {
		if(str == null) return true;
		if("".equals(str.replaceAll(" ", ""))) return true;
		return false;
	}
}
